<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/4/004
 * Time: 10:37
 */

namespace Admin\Model;

use Think\Model;
class GoodsorderModel extends Model
{
    protected $selectField = ['o.id','o.order_sn', 'o.real_pay_amount', 'o.send_goods', 'o.add_time', 'g.goods_sn','g.goods_name', 'r.tel'];
    //获取订单列表
    public function getOrderList($where, $field = null, $order = 'add_time desc') {
        if($field == null) {
            $field = $this->selectField;
        }

        $count = $this->alias('o')
            ->join('__GOODS__ g on o.goods_id = g.id')
            ->join('__REGISTER__ r on o.user_id = r.id')
            -> where($where)->count();

        $list = M('Goodsorder')->alias('o')
            ->join('__GOODS__ g on o.goods_id = g.id')
            ->join('__REGISTER__ r on o.user_id = r.id')
            ->field($field)
            ->where($where)
            ->page(I('p', 1, 'intval'))->limit(15)
            ->order($order)->select();

        return ['list'=>$list, 'count' => $count];
    }
}